<script src="<?php echo base_url('theme/third_party/rating/lib/jquery.raty.min.js'); ?>" type="text/javascript"></script>
<?php if ($ads): ?>
  <?php if(!isset($extra)): ?>
  <ul class="thumbnails items">
  <?php endif; ?>
  
    <?php $i=0; foreach ($ads as $ad): ?>
      <?php if ($i == 0 || $i == 11): ?>
        <li style="width: 463px; height: 411px; <?php if($i == 11):?>float:right;<?php endif; ?>">
          <a style="display:block; height:368px; position:relative;" rel="mainPopup[ajax]" href="<?php echo base_url('rao-vat/true/' . $ad['ad_id']); ?>" data-url="<?php echo '/rao-vat/' . $ad['slug'] . '/' . generalSlug($ad['title']); ?>" >
            <img style="position:absolute;top:0;left:0;bottom:0;right:0;margin:auto;width: 460px; height: 336px;" src="<?php echo base_url('upload/ad/avatar/' . $ad['user_id'] . '/' . $ad['avatar']); ?>">
          </a>
          <div class="caption">
            <div style="margin-top: 6px; border:1px dashed #C6C6C6"></div>
            <h6><?php echo characterLimiter($ad['title'],64); ?></h6>
            <div><?php echo getAdCategories($ad['category_id']); ?></div>
          </div>
        </li>
      <?php else: ?>
        <li>
          <a style="display:block; height:155px; position:relative;" rel="mainPopup[ajax]" href="<?php echo base_url('rao-vat/true/' . $ad['ad_id']); ?>" data-url="<?php echo '/rao-vat/' . $ad['slug'] . '/' . generalSlug($ad['title']); ?>" >
            <img style="position:absolute;top:0;left:0;bottom:0;right:0;margin:auto;" <?php /*width="224" height="155"*/ ?> src="<?php echo base_url('upload/ad/avatar/' . $ad['user_id'] . '/' . $ad['avatar']); ?>">
          </a>
          <div class="caption">
            <div style="margin-top: 6px; border:1px dashed #C6C6C6"></div>
            <h6><?php echo characterLimiter($ad['title'], 30); ?></h6>
            <div><?php echo getAdCategories($ad['category_id']); ?></div>
          </div>
        </li>
      <?php endif; $i++ ?>
    <?php endforeach; ?>
  
  <?php if(!isset($extra)): ?>
  </ul>
  <script type="text/javascript">
    // Thanh cuộn load thêm nội dung
    $(document).ready(function(){
    	  
    // js.js
    mainPopup('ad');
    	  
  	var company_extra=0;
  	window.onscroll=function(){
  	  scrollY=window.pageYOffset;
  	  scrollMaxY=document.documentElement.scrollHeight-document.documentElement.clientHeight;
  	  if(scrollY==scrollMaxY){
  		  company_extra++; //s tăng lên một mỗi lần cuộn
  		var url = '<?php echo base_url('ad/index'); ?>';
  		var url = url + '\/' + company_extra + '/true';
  
  		$.get(url, function(data) {
  	 	  $('.items').append(data); // append to <ul>
  
      	  // js.js
      	  mainPopup('ad');
  	 	  
  	 	});
  	  }
  	}; // end onscroll
  	
    });
  </script> 
  <?php endif; ?>
<?php else: ?>
	Không tồn tại rao vặt nào.
<?php endif; // $companys ?>